package com.leech.dubbo.consumer;

import java.util.List;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.leech.dubbo.bean.User;
import com.leech.dubbo.service.DemoService;

public class Consumer {
	public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"consumer.xml"});
        context.start();
  
        DemoService demoService = (DemoService)context.getBean("demoService"); // 获取远程服务代理
        String res = demoService.sayHello("world"); // 执行远程方法
        System.out.println( res ); // 显示调用结果
        
        List<User> users = demoService.getUsers();
        if (users != null && users.size() > 0) {  
            for (int i = 0; i < users.size(); i++) {  
                System.out.println(users.get(i));  
            }  
        }  
        
        context.close();
    }
}
